<?php

namespace app\index\controller;

use app\common\controller\Log;
use app\common\model\Member;
use app\common\model\MemberFinance;
use app\common\model\MemberPackages;
use app\common\model\Packages;
use app\common\model\UcenterMember;
use think\Db;
use app\common\model\Traders as tradersModel;
use app\common\api\controller\Bonus;
use app\common\api\controller\User as UserApi;
use app\common\api\controller\Error;
use think\Request;
use think\Validate;


class MemberGroup extends Home
{
    private static $model;

    protected $beforeActionList = [
        'check_load'
    ];

    public function __construct(Request $request = null)
    {
        parent::__construct($request);

        self::$model = new \app\common\model\MemberGroups();
    }

    /**
     * 券商列表
     */
    public function lists()
    {
        $uid = $this->uid;

        $lists = self::$model->where('status', 1)
            ->order('id asc')
            ->select();

        if (count($lists) > 0) {
            foreach ($lists as $k=>$v) {
                $v->avatar = $v->avatar > 0 ? get_cover($v->avatar, 'path') : '';
            }
        }

        $this->apiSuccess('市商列表', ['list' => $lists, 'totalCount' => $totalCount]);
    }

    /**
     * Notes:群组详情
     * User: Administrator
     * Date: 2023/9/13
     * Time: 11:38
     */
    public function one()
    {
        $id = input('id');
        $rowInfo = self::$model->find($id);
        if (!$rowInfo) {
            $this->apiError('该群组不存在');
        }

        $number = \app\common\model\MemberGroupsChat::where('group_id', $id)->count();
        $rowInfo->memberCounts = (string)$number;

        $this->apiSuccess('群组信息', $rowInfo);
    }
}